package com.example.Lezedata.ui.fragment;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.example.Lezedata.R;
import com.example.Lezedata.ui.activity.baseClass.GBBaseVc;

public class BaseDiaLogFragment extends DialogFragment {
    public String TAG;
    public View contentView;
    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        TAG = getClass().getName();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        contentView = view;
        initView();
    }

    public int Gravity(){
        return Gravity.BOTTOM;
    }

    public int windowAnimationsType(){
        return 0;
    }

    public void onStart() {
        WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
        int resId = windowAnimationsType();
        if (resId != 0){
            getDialog().getWindow().setWindowAnimations(resId);
        }
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//设置背景为透明
        params.width = ViewGroup.LayoutParams.MATCH_PARENT;//设置宽度为铺满
        params.gravity = Gravity();
        getDialog().getWindow().setAttributes(params);
        super.onStart();
    }

    public final <T extends View> T findViewById(int id){
        return contentView.findViewById(id);
    }

    public final <T extends View> T findViewWithTag(Object object){
        return contentView.findViewWithTag(object);
    }

    public GBBaseVc baseVc(){
        return (GBBaseVc)this.getActivity();
    }

    public void initView(){}
}
